﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace PTTPOS_Solution.DAL
{
    public class Surcharge_DAL
    {
        public static DataTable ListSurchargeReason = new DataTable();
        public static void GetListSurcharge()
        {
            MySqlCommand com = new MySqlCommand("select * from tblsurcharges", Connection_PTTPOS.GetConnection());
            com.Connection.Open();
            MySqlDataAdapter da = new MySqlDataAdapter(com);
            ListSurchargeReason.Clear();
            da.Fill(ListSurchargeReason);
            com.Connection.Close();
        }
        public static DataTable listSurcharge(string id)
        {
            DataTable tbl = new DataTable();
            MySqlCommand com = new MySqlCommand("select * from tblsurcharges where id=@id", Connection_PTTPOS.GetConnection());
            com.Parameters.AddWithValue("@id", id);
            com.Connection.Open();
            MySqlDataAdapter adapter = new MySqlDataAdapter(com);
            adapter.Fill(tbl);
            com.Connection.Close();
            return tbl;
        }
        public static void UpdateSurcharge(string id, string Rebateform, string Value)
        {
            MySqlCommand com = new MySqlCommand("update tblsurcharges set Rebateform=@Rebateform, Value=@Value where id=@id", Connection_PTTPOS.GetConnection());
            com.Parameters.AddWithValue("@id", id);
            com.Parameters.AddWithValue("@Rebateform", Rebateform);
            com.Parameters.AddWithValue("@Value", Value);
            com.Connection.Open();
            com.ExecuteNonQuery();
            com.Connection.Close();
        }
    }
}
